package com.urfresh.sp.flume.dto.v2;

import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.NotEmpty;

import java.util.Date;

/**
 * 用户落地页的提交信息
 * Created by urfresh.mark on 2016/8/24.
 */
public class PageInfo {

    @ApiModelProperty(value = "页面来源，可以设定为来自哪个第三方市场，或者来自urfresh自己的渠道", required = true)
    @NotEmpty(message = "页面来源不能为空")
    String source;

    @ApiModelProperty(value = "页面渠道，如美妆，3c，新闻等投放渠道", required = true)
    @NotEmpty(message = "页面渠道不能为空")
    String channel;

    @ApiModelProperty(value = "页面名称", required = true)
    @NotEmpty(message = "页面名称不能为空")
    String page;

    @ApiModelProperty(value = "来源类型，应用市场，超级APP，门户，SEM，BD", required = true)
    @NotEmpty(message = "来源类型不能为空")
    String sourceType;

    @ApiModelProperty(value = "促销活动类型", required = false)
    String promoType;

    @ApiModelProperty(value = "促销活动名称", required = false)
    String promoName;

    @ApiModelProperty(value = "广告类型(广告在展示页面中的类型)", required = false)
    String advType;

    @ApiModelProperty(value = "附加信息", required = false)
    String desc;

    @ApiModelProperty(value = "客户端无需传递", required = false)
    String ip;

    @ApiModelProperty(value = "客户端无需传递", required = false)
    String userAgent;

    @ApiModelProperty(value = "客户端无需传递", required = false)
    String platform;

    @ApiModelProperty(value = "客户端无需传递", required = false)
    String isActive;

    @ApiModelProperty(value = "客户端无需传递", required = false)
    Date activeTime;

    @ApiModelProperty(value = "曝光:expose/点击:click", required = false)
    String type;

    String target;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public String getPlatform() {
        return platform;
    }

    public void setPlatform(String platform) {
        this.platform = platform;
    }

    public String getIsActive() {
        return isActive;
    }

    public void setIsActive(String isActive) {
        this.isActive = isActive;
    }

    public Date getActiveTime() {
        return activeTime;
    }

    public void setActiveTime(Date activeTime) {
        this.activeTime = activeTime;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getSourceType() {
        return sourceType;
    }

    public void setSourceType(String sourceType) {
        this.sourceType = sourceType;
    }

    public String getPromoType() {
        return promoType;
    }

    public void setPromoType(String promoType) {
        this.promoType = promoType;
    }

    public String getPromoName() {
        return promoName;
    }

    public void setPromoName(String promoName) {
        this.promoName = promoName;
    }

    public String getAdvType() {
        return advType;
    }

    public void setAdvType(String advType) {
        this.advType = advType;
    }

    public static PageInfo buildPageInfo(PageInfo pageInfo, String userAgent, String ip){
        if(userAgent.contains("iPhone") || userAgent.contains("iPad"))
            pageInfo.setPlatform("ios");
        else if(userAgent.contains("Android"))
            pageInfo.setPlatform("Android");
        else if(userAgent.contains("Windows Phone"))
            pageInfo.setPlatform("Windows Phone ");
        else
            pageInfo.setPlatform("pc");
        pageInfo.setIp(ip);
        return pageInfo;
    }
}
